<template>
  <div>
    <div class="topSearch">
      <div class="leftBox" style="max-width:100%;">
        <div class="searchbox">
            <em>所在校区：</em>
            <el-select v-model="searchBox.schoolId" filterable size="small" placeholder="请选择学年">
              <el-option v-for="(item,index) in conditionBox.schoolList" :key="index" :label="item.schoolName" :value="item.schoolId"></el-option>
            </el-select>
          </div>
          <div class="searchbox">
            <em>学生姓名：</em>
            <el-input v-model="searchBox.studentName" clearable style="width:120px;" size="small" placeholder="请输入内容"></el-input>
          </div>
          <div class="searchbox">
            <em>身份证号：</em>
            <el-input v-model="searchBox.idCard" clearable style="width:150px;" size="small" placeholder="请输入内容"></el-input>
          </div>
          <div class="searchbox">
            <el-button type="primary" @click="getData" size="mini">查询</el-button>
          </div>
      </div>
      <div class="clear"></div>
    </div>

    <div>
       <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="学籍系统" name="1">
            <el-table :data="tableData" style="width: 100%" height="550">
              <el-table-column prop="studentName" label="学生姓名"></el-table-column>
              <el-table-column prop="idCard" label="身份证号" width="200"></el-table-column>
              <el-table-column prop="attendSchoolName" label="所在校区" width="200"></el-table-column>
              <el-table-column prop="sectionName" label="学段"></el-table-column>
              <el-table-column prop="gradeName" label="年级"></el-table-column>
              <el-table-column prop="className" label="班级" width="150"></el-table-column>
              <el-table-column prop="paymentCategoryName" label="学生类型" width="150"></el-table-column>
              <el-table-column prop="finishSchoolYear" label="毕业年份"></el-table-column>
              <el-table-column prop="entranceTotalScore" label="入学成绩"></el-table-column>
              <el-table-column prop="bonusScore" label="政策加分"></el-table-column>
              <el-table-column prop="payStatus" label="缴费状态"></el-table-column>
              <el-table-column v-for="(a,index) in proList" :key="index" :label="a.projectName">
                <el-table-column :prop="a.billDate" label="单据日期"></el-table-column>
                <el-table-column :prop="a.billnum" label="账单编号" width="180"></el-table-column>
                <el-table-column label="各项费用总计">
                  <el-table-column v-for="(b,index1) in a.projectItemList" :key="index1" :prop="b.moneyNum" width="120" :label="b.itemName"></el-table-column>
                </el-table-column>
                <el-table-column :prop="a.reductionSum" label="减免金额"></el-table-column>
                <el-table-column :prop="a.payableMoney" label="应收合计"></el-table-column>
                <el-table-column :prop="a.paidMoney" label="实收合计"></el-table-column>
                <el-table-column :prop="a.differResult" label="差异"></el-table-column>
                <el-table-column :prop="a.refundMoney" label="退费金额"></el-table-column>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="报名系统" name="2">
            <el-table :data="tableData1" style="width: 100%" height="550">
              <el-table-column prop="studentName" label="学生姓名"></el-table-column>
              <el-table-column prop="idCard" label="身份证号" width="200"></el-table-column>
              <el-table-column prop="attendSchoolName" label="所在校区" width="200"></el-table-column>
              <el-table-column prop="paymentCategoryName" label="学生类型" width="150"></el-table-column>
              <el-table-column prop="finishSchoolYear" label="毕业年份"></el-table-column>
              <el-table-column prop="isShiftIn" label="是否插班生">
                <template>

                </template>
              </el-table-column>
              <el-table-column prop="totalScore" label="中考裸分"></el-table-column>
              <el-table-column prop="bonusScore" label="预报名加分"></el-table-column>
              <el-table-column prop="bonusScore" label="政策加分"></el-table-column>
              <el-table-column prop="payStatus" label="缴费状态"></el-table-column>
              <el-table-column v-for="(a,index) in proList1" :key="index" :label="a.projectName">
                <el-table-column :prop="a.billDate" label="单据日期"></el-table-column>
                <el-table-column :prop="a.billnum" label="账单编号" width="180"></el-table-column>
                <el-table-column label="各项费用总计">
                  <el-table-column v-for="(b,index1) in a.projectItemList" :key="index1" :prop="b.moneyNum" width="120" :label="b.itemName"></el-table-column>
                </el-table-column>
                <el-table-column :prop="a.reductionSum" label="减免金额"></el-table-column>
                <el-table-column :prop="a.payableMoney" label="应收合计"></el-table-column>
                <el-table-column :prop="a.paidMoney" label="实收合计"></el-table-column>
                <el-table-column :prop="a.differResult" label="差异"></el-table-column>
                <el-table-column :prop="a.refundMoney" label="退费金额"></el-table-column>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>

    </div>
  </div>
</template>

<script>
export default {
  name:'personalAll',
  data() {
    return {
      ccc:'个人总报表',
      activeName:"1",
      searchBox:{
        schoolId:'',
        studentName:'和晓熙',
        idCard:''
      },
      conditionBox:{
        schoolList:[]
      },
      tableData:[],
      tableData1:[],
      proList:[],
      proList1:[]
    }
  },
  mounted() {
    this.getSchool();
    // this.getData();
  },
  methods: {
    // 获取学校
    getSchool(){
      let that = this;
      that.$api.trainingReduction.GetSpecialSrainingSchoolList().then(res=>{
        console.log("获取学校",res);
        that.conditionBox.schoolList = res.data.result;
        if(res.data.result.length > 0){
          that.searchBox.schoolId = "14";
          //  that.searchBox.schoolId = res.data.result[0].schoolId;
          //  that.getData()
        }

      })
    },
    // 获取报表数据
    getData(){
      // return;
      this.$api.reportForm.GetPersonalForm(this.activeName,this.searchBox.schoolId,this.searchBox.studentName,this.searchBox.idCard).then(res=>{
        console.log("获取报表数据",res);
        if(this.activeName==="1"){
          let proList = res.data.result.projects;
          let datalist = res.data.result.datas;
          datalist.forEach(aaa=>{
            if(aaa.xjBillViews!=null){
            aaa.xjBillViews.forEach(bbb=>{
              proList.forEach(abc=>{
                if(bbb.projectId===abc.projectId){
                  abc.billnum = abc.projectId+'_billNumber';                //订单号
                  abc.billDate = abc.projectId+'_billDate';                 //订单日期
                  abc.reductionSum = abc.projectId+'_reductionSum';         //减免
                  abc.refundMoney = abc.projectId+'_refundMoney';           //退费
                  abc.payableMoney = abc.projectId+'_payableMoney';         //应收合计
                  abc.paidMoney = abc.projectId+'_paidMoney';               //实收合计
                  abc.differResult = abc.projectId+'_differResult';               //差异
                  aaa[abc.projectId+'_billNumber'] = bbb.billNumber;
                  aaa[abc.projectId+'_billDate'] = bbb.paidTime;
                  aaa[abc.projectId+'_reductionSum'] = bbb.reductionSum==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_refundMoney'] = bbb.refundMoney==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_payableMoney'] = bbb.payableMoney==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_paidMoney'] = bbb.paidMoney==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_differResult'] = bbb.differResult==null?0:bbb.reductionSum;
                }
                abc.projectItemList.forEach(bcd=>{
                  bbb.xjStudentFeeDetails.forEach(ccc=>{
                    if(ccc.itemId===bcd.itemId && ccc.projectId===bcd.projectId){
                      bcd.moneyNum = bcd.itemId+'_money';
                      aaa[bcd.itemId+'_money'] = ccc.money;
                    }
                  })
                })
              })
            })
            }
          })
          this.tableData = datalist;
          this.proList = proList;


        }else{
          let proList = res.data.result.projects;
          let datalist = res.data.result.datas;
          datalist.forEach(aaa=>{
            if(aaa.xjBillViews!=null){
            aaa.xjBillViews.forEach(bbb=>{
              proList.forEach(abc=>{
                if(bbb.projectId===abc.projectId){
                  abc.billnum = abc.projectId+'_billNumber';                //订单号
                  abc.billDate = abc.projectId+'_billDate';                 //订单日期
                  abc.reductionSum = abc.projectId+'_reductionSum';         //减免
                  abc.refundMoney = abc.projectId+'_refundMoney';           //退费
                  abc.payableMoney = abc.projectId+'_payableMoney';         //应收合计
                  abc.paidMoney = abc.projectId+'_paidMoney';               //实收合计
                  abc.differResult = abc.projectId+'_differResult';               //差异
                  aaa[abc.projectId+'_billNumber'] = bbb.billNumber;
                  aaa[abc.projectId+'_billDate'] = bbb.paidTime;
                  aaa[abc.projectId+'_reductionSum'] = bbb.reductionSum==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_refundMoney'] = bbb.refundMoney==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_payableMoney'] = bbb.payableMoney==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_paidMoney'] = bbb.paidMoney==null?0:bbb.reductionSum;
                  aaa[abc.projectId+'_differResult'] = bbb.differResult==null?0:bbb.reductionSum;
                }
                abc.projectItemList.forEach(bcd=>{
                  bbb.xjStudentFeeDetails.forEach(ccc=>{
                    if(ccc.itemId===bcd.itemId && ccc.projectId===bcd.projectId){
                      bcd.moneyNum = bcd.itemId+'_money';
                      aaa[bcd.itemId+'_money'] = ccc.money;
                    }
                  })
                })
              })
            })
            }
          })
          this.tableData1 = datalist;
          this.proList1 = proList;
          // this.tableData1 = res.data.result.datas;
          // this.proList1 = res.data.result.projects;
        }
      })
    },
    // 切换
    handleClick() {
      this.getData()
    }
  }
}
</script>

<style>

</style>
